<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>添加用户</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<jsp:include page="../common.jsp"/>
	<style type="text/css">
		.password_strength{padding: 0px}
	</style>
	<script type="text/javascript">
		$(function() {
			var ids=new Array();
			<c:forEach items="${user.pubRoles}" var="e" varStatus="i">
			ids[${i.index}]="${e.roleId}";
			</c:forEach>
			$("input[name=pubRoles]").each(function(i,e) {
				$(ids).each(function(ii,ee) {
					if (e.value==ee) {
						e.checked=true;
						return false;
					}
				});
			});
		});
	</script>
  </head>
  <body>
    <f:form action="sys/user/doAdd" modelAttribute="user">
		<div class="box1" panelWidth="100%">
		<fieldset> 
			<legend>新增用户</legend> 
			<table class="tableStyle" formMode="transparent" footer="normal">
				<tr>
					<td width="15%">登录用户名：</td>
					<td width="35%">
						<f:input path="userAccount"/>
						<span class="star">*</span>
						<f:errors path="userAccount" cssStyle="color:red"/>
					</td>
				</tr>
				<tr>
					<td width="15%">用户姓名：</td>
					<td>
						<f:input path="userName"/>
					</td>
				</tr>
				<tr>
					<td width="15%">用户密码：</td>
					<td>
						<f:password path="userPassword" checkStrength="true"/>
						<span class="star">*</span>
						<f:errors path="userPassword" cssStyle="color:red"/>
					</td>
				</tr>
				<tr>
					<td width="15%">用户描述：</td>
					<td>
						<f:textarea path="userDesc"/>
					</td>
				</tr>
				<tr>
					<td width="15%">启用状态：</td>
					<td>
						<f:radiobutton path="enabled" value="true"/>启用
						<f:radiobutton path="enabled" value="false"/>禁用
					</td>
				</tr>
				<tr>
					<td width="15%">角色列表：</td>
					<td>
						<f:checkboxes items="${list}" itemLabel="roleName" itemValue="roleId" path="pubRoles" delimiter="<br>"/>
						<span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td></td>
					<td>
						<div><f:errors path="pubRoles" cssStyle="color:red"/></div>
					</td>
				</tr>
			</table>
		</fieldset> 
		<div class="height_5"></div>
		<div class="padding_top10">
			<table class="tableStyle" formMode="transparent">
				<tr>
					<td colspan="4">
						<input type="submit" value="提交" id="button1"/>
						<input type="button" value="返回" onclick="location.href='<%=basePath%>sys/user/list'"/>
					</td>
				</tr>
			</table>
		</div> 
	</div>
	</f:form>
  </body>
</html>
